package com.gxa.sideParking.admin.controller;


import com.gxa.sideParking.admin.service.CarService;
import com.gxa.sideParking.core.common.JsonResult;
import com.gxa.sideParking.core.exception.BusinessException;
import com.gxa.sideParking.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gxa
 * @since 2022-10-05
 */
@RestController
@RequestMapping("/sideParking/car")
public class CarController {

    @Autowired
    private CarService carService;

    //查询所有
    @GetMapping("/findAll")
    public JsonResult findAll(Integer currentPage,Integer pageSize) throws BusinessException {
        return carService.findAll(currentPage,pageSize);
    }

    //按车牌号查询
    @GetMapping("/findCarNum")
    public JsonResult findCarNum(String carNum) throws BusinessException{
        return carService.findCarNum(carNum);
    }

    //按用户名查询
    @GetMapping("/findName")
    public JsonResult findName(String userNickName) throws BusinessException{
        return carService.findName(userNickName);
    }

    //修改车辆绑定状态
    @PostMapping("/updateStatus")
    public JsonResult updateStatus(Integer carStatus) throws BusinessException{
        return carService.updateStatus(carStatus);
    }

    //修改启用状态
    @PostMapping("updateForbidden")
    public int updateForbidden(Integer carForbidden) throws BusinessException{
        return carService.updateForbidden(carForbidden);
    }
}

